package dao;

import org.apache.ibatis.annotations.*;
import pojo.DoctorWork;
import pojo.WorkPlan;

import java.util.Date;
import java.util.List;

@Mapper
public interface WorkPlanMapper {

    @Select("SELECT * FROM work_plan")
    List<WorkPlan> findAll();

    @Select("SELECT * FROM work_plan WHERE day = #{day}")
    WorkPlan findByDay(Date day);

    @Insert("INSERT INTO work_plan(day, weekday, status, create_by) " +
            "VALUES(#{day}, #{weekday}, #{status}, #{createBy})")
    int addWorkPlan(WorkPlan workPlan);

    @Update("UPDATE work_plan SET " +
            "weekday = #{weekday}, " +
            "status = #{status} " +
            "WHERE day = #{day}")
    int updateWorkPlan(WorkPlan workPlan);

    @Delete("DELETE FROM work_plan WHERE day = #{day}")
    int deleteWorkPlan(Date day);

    @Select("SELECT * FROM doctor_work WHERE weekday = #{week}")
    List<DoctorWork> getWorkPlanByWeek(@Param("week") String week);
}